/*
 ============================================================================
 Name        :	w_parser.h
 Author      :	NAYED (nizar.ayed@fullcommedia.com)
 Version     :	0.1
 Copyright   :	Code delivered as is with no liability. No commercial use
				is allowed without written authorization from the Author.
 Description :
	In general, the source code is compiled to:
	- Generate the objects' protos' tree and owners' tree
	- and Set objects' payloads
	Payloads are of 2 kinds:
	- Value (string, integer, float)
	- Objects' array (in fact, this is the pseudo-compiled code)
	The pseudo-compiled code is structured in RPN (Reverse Polish Notation) using
	message structure. Therefore, when executed, the code is loaded in a pile. Example:
	- To add 2 objects:
		+ obj1 is loaded in the pile
		+ obj2 is loaded in the pile
		+ "+" is loaded in the pile and executed (as an operator that takes the 
			last 2 items in the pile and return the sum instead)
	
	The parser is used to extract tokens from the code and send them to the 
	execution engine (or pseudo-compiler). The code is compound of (BNF notation):
	- identifier ::= alpha {alpha | digit}
	- alpha ::= letter | symbol
    - letter  ::= <a> | <b> | <c> | .. | <z>
	- digit  ::= <0> | <1> | <2> | .. | <9>
	- symbol ::= <_> | <$>
	- int ::= {sign} digit {digit}
	- sign ::= <+> | <->
	- float ::= int <.> digit {digit} [exposant]
	- exposant ::= (<e> | <E>) int
	- string ::= <"> {p_car | esc_car | hex_car} <">
	- p_car ::= { <any printable car> }
	- esc_car ::= <\>(<">|<?>|<\>|<a>|<b>|<f>|<n>|<r>|<t>|<v>)
	- hex_car ::= <\> (<x>|<X>) digit digit
    - proc ::= <[> {params} <|> {code} <]>
	- func ::= <{> {params} <|> {code} <}>
	- params ::= indentifier {<,> indentifier}
    - code ::= instruction { separator instruction }
	- separator ::= <space> | <new-line>
	- instruction ::= proc | func | int | float | string | identifier | equal
	- equal ::= <=>
	- comment_line ::= <#> {car} <EOL>
	- car ::= <any character besides EOL>
	- comment_multiln ::= </> <*> {car | <EOL>} <*> </>
	
 ============================================================================
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#ifndef W_PARSER_H_
#define W_PARSER_H_

#define MAX_TOKEN_SIZE	1024

#define READ_CHAR		1
#define READ_WORD		2
#define IS_SYMBOL		3
#define IS_DIGIT		4
#define IS_LETTER		5
#define IS_ALPHA		6
#define IS_SIGN			7
#define IS_P_CAR		8
#define IS_ESC_CAR		9
#define IS_SPACE		10
#define IS_IDENTIFIER	11
#define IS_INT			12
#define IS_FLOAT		13
#define IS_EXPOSANT		14
#define IS_STRING		15
#define IS_HEX_CAR		16
#define IS_PROC			17
#define IS_FUNC			18
#define IS_PARAMS		19
#define IS_CODE			20
#define IS_INSTRUCTION	21
#define IS_EQUAL		22
#define IS_COMMENT_LINE	23
#define IS_COMMENT_MULTILN	24
#define IS_HEX_DIGIT	25

typedef enum { false, true } bool;
typedef enum { ok, unknown, error } status;
char *result_buffer; /* Multiple purpose buffer */

char read_char(char *);
char* read_word(FILE *);
bool is_symbol(char);
bool is_digit(char);
bool is_letter(char);
bool is_alpha(char);
bool is_sign(char);
bool is_p_car(char);
bool is_esc_car(char *);
bool is_space(char);
bool is_identifier(char *);
bool is_int(char *);
bool is_float(char *);
bool is_exposant(char *);
bool is_string(char *);
bool is_hex_car(char *);
bool is_hex_digit(char);
bool is_proc(char *);
bool is_func(char *);
bool is_params(char *);
bool is_code(char *);
bool is_instruction(char *);
bool is_equal(char *);
bool is_comment_line(char *);
bool is_comment_multiln(char *);
#endif	/* W_PARSER_H_ */